//
//  HQAdViewController.m
//  HQNews
//
//  Created by 韩家奇 on 15/12/13.
//  Copyright © 2015年 韩家奇. All rights reserved.
//

#import "HQAdViewController.h"
#import "HQTabBarController.h"
@interface HQAdViewController ()

@end

@implementation HQAdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //1.谁知背景图片
    UIImageView *backgroundImageView = [[UIImageView alloc]initWithImage:
    [UIImage imageNamed:@"Default"]];
    [self.view addSubview:backgroundImageView];
    backgroundImageView.frame = self.view.bounds;
    
    //2.设置广告图片
    UIImageView *adImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ad"]];
    [self.view addSubview:adImageView];
    
    adImageView.width = 306;
    adImageView.height = 310;
    adImageView.centerX = self.view.width *0.5;
    adImageView.centerY = self.view.width *0.4;
    //3.广告2秒后 获取主窗口,跳转到mainTabVC
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        //3.1获取主窗口
        UIWindow *window = [UIApplication sharedApplication].keyWindow;
        //3.2创建uitabbarcontroller
        HQTabBarController *mainTabBarVc = [[HQTabBarController alloc] init];
        
        //3.3设置uiwindow的跟控制器 为maintabbar
        window.rootViewController = mainTabBarVc;
    });
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
